package com.site.config;

import com.site.controller.OneInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by shengquan.wu on 2018/6/6.
 */
@Configuration
public class DemoConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new OneInterceptor()).addPathPatterns("/one/**");

        /**
         * 如果有多个拦截器，将按照顺序执行
         * registry.addInterceptor(new OneInterceptor()).addPathPatterns("/one/**");
         * registry.addInterceptor(new TwoInterceptor()).addPathPatterns("/two/**");
         *
         * 还可以同时拦截多个：
         * registry.addInterceptor(new TwoInterceptor()).addPathPatterns("/one/**").addPathPatterns("/two/**");
         */

        super.addInterceptors(registry);
    }
}
